<%@ page contentType="text/html; charset=utf-8" %><%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt"%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%><%@ taglib prefix="fmt_rt" uri="http://java.sun.com/jstl/fmt_rt"%><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%><%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"%><%@ taglib prefix="x_rt" uri="http://java.sun.com/jstl/xml_rt"%><%@ taglib prefix="wr_fn" uri="http://njo.org/taglib/functions"%>
--
-- ${gdata.gen_name}
-- ${gdata.description }
-- Database:${gdata.gen_to_kind}
--
<c:forEach items="${gdata.fieldSetList}" var="item" varStatus="itemStatus">
--
--${item.field_set_description}
--
CREATE TABLE ${item.field_set_physical_name} (<c:forEach items="${item.fields}" var="fielditem" varStatus="fieldItemStatus"><c:set var="f_l_" value="${wr_fn:isEmpty(fielditem.field_size) ? '' : '('}"/><c:set var="f_r_" value="${wr_fn:isEmpty(fielditem.field_size) ? '' : ')'}"/>
    ${fielditem.field_physical_name} ${fielditem.field_type}${f_l_}${wr_fn:isEmpty(fielditem.field_size) ? '' : fielditem.field_size}${f_r_} ${fielditem.allow_null eq 'on' ? '' : 'NOT NULL'}${fieldItemStatus.last ? '' : ','}</c:forEach>
)
</c:forEach>

<c:forEach items="${gdata.fieldSetList}" var="item" varStatus="itemStatus"><c:set var="pkf" value=""/><c:forEach items="${item.fields}" var="fielditem" varStatus="fieldItemStatus"><c:if test="${fielditem.primary_key eq 'on'}"><c:set var="pkf">${pkf}${wr_fn:isEmpty(pkf) ? '' : ','}${fielditem.field_physical_name}</c:set></c:if></c:forEach>
<c:if test="${!wr_fn:isEmpty(pkf)}">ALTER TABLE ${item.field_set_physical_name} ADD PRIMARY KEY (${pkf});</c:if></c:forEach>

